Skip to content

fix(pfe-tools): end-anchor TS redirect regex to avoid rewriting .js.map#3144

Open
bennypowers wants to merge 1 commit into
staging/pfv6from
fix/pfe-tools-ts-redirect
Open

fix(pfe-tools): end-anchor TS redirect regex to avoid rewriting .js.map#3144
bennypowers wants to merge 1 commit into
staging/pfv6from
fix/pfe-tools-ts-redirect

Conversation

@bennypowers
Copy link
Copy Markdown
Member

@bennypowers bennypowers commented May 12, 2026

Summary

  • The .js regex in liveReloadTsChangesMiddleware was not end-anchored, so requests for .js.map (source maps) were matched and rewritten to .ts.map, breaking source maps
  • End-anchor the regex (\.js$) and use regex replacement so only the final .js extension is rewritten

Test plan

  • npm run dev serves elements correctly
  • Source maps (.js.map) load without 404 or redirect

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

⚠️ No Changeset found

Latest commit: 957c67c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

✅ Commitlint tests passed!

More Info
{
  "valid": true,
  "errors": [],
  "warnings": [],
  "input": "fix(pfe-tools): end-anchor TS redirect regex to avoid rewriting .js.map"
}

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

Deploy Preview for patternfly-elements ready!

Name Link
🔨 Latest commit e8a44ab
😎 Deploy Preview https://deploy-preview-3144--patternfly-elements.netlify.app/

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions Bot added the AT passed Automated testing has passed label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for 7d94b15: Report

@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for e8a44ab: Report

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the PFE dev-server request handling to improve TypeScript-source resolution when .js files are requested but only .ts sources exist in the repo, reducing 404s during local development and test runs.

Changes:

  • Adjusts liveReloadTsChangesMiddleware to run after downstream middleware and only redirect when the response is a 404.
  • Removes the inline comment describing the previous regex capture-group behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/pfe-tools/dev-server/config.ts Outdated
Comment thread tools/pfe-tools/dev-server/config.ts Outdated
Copy link
Copy Markdown
Collaborator

@zeroedin zeroedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on resolution of the copilot reviews

@bennypowers bennypowers changed the title fix(pfe-tools): use WDS plugin for TS redirect instead of koa middleware fix(pfe-tools): redirect .js to .ts only on 404 May 23, 2026
The `.js` regex in `liveReloadTsChangesMiddleware` was not end-anchored,
so requests for `.js.map` (source maps) were also matched and rewritten
to `.ts.map`, breaking source maps in the dev server.

End-anchor the regex (`\.js$`) and use a regex replacement to ensure
only the final `.js` extension is rewritten to `.ts`.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bennypowers bennypowers changed the title fix(pfe-tools): redirect .js to .ts only on 404 fix(pfe-tools): end-anchor TS redirect regex to avoid rewriting .js.map May 23, 2026
@bennypowers bennypowers force-pushed the fix/pfe-tools-ts-redirect branch from c0b44f9 to 957c67c Compare May 23, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AT passed Automated testing has passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants